package com.wj.rspmproperty.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.wj.rspmproperty.mapper.RoomMapper;
import com.wj.rspmproperty.pojo.PageResult;
import com.wj.rspmproperty.pojo.Room;
import com.wj.rspmproperty.service.RoomService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

/**
 * @author WeiJin
 * @version 1.0
 */
@Service
@Transactional
public class RoomServiceImpl implements RoomService {

    @Autowired
    private RoomMapper roomMapper;

    @Override
    public List<Room> roomOfFloor(Integer floorId) {
        return roomMapper.roomOfFloor(floorId);
    }

    @Override
    public PageResult<Room> pageOfRoom(Map<String, String> map) {

        PageHelper.startPage(Integer.parseInt(map.get("current")),Integer.parseInt(map.get("size")));
        Page<Room> rooms = roomMapper.pageOfRooms(map);
        return PageResult.restPage(rooms);
    }

    @Override
    public Integer changeRoomsStatus(List<Integer> ids, Integer status) {
        return roomMapper.changeRoomStatus(ids,status);
    }
}
